package com.probos.bosnatuur.monitor;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class ProjectTab extends TabActivity {
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.project_tab);

    	Bundle extras = getIntent().getExtras();
    	Long project_id = (long) 0;
    	String strTitle = "";
	    
	    if (extras != null) {
	    	project_id = extras.getLong(ProjectDbAdapter.KEY_ROWID);
	    	strTitle = extras.getString(ProjectDbAdapter.KEY_TITLE);
	    	setTitle(strTitle);
	    }

	    Resources res = getResources(); // Resource object to get Drawables
	    TabHost tabHost = getTabHost();  // The activity TabHost
	    TabHost.TabSpec spec;  // Resusable TabSpec for each tab
	    Intent intent;  // Reusable Intent for each tab

	    // Create an Intent to launch an Activity for the tab (to be reused)
	    intent = new Intent().setClass(this, ProjectElements.class);
	    intent.putExtra(ProjectDbAdapter.KEY_ROWID, project_id);
	    intent.putExtra(ProjectDbAdapter.KEY_TITLE, strTitle);
	    
	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("elements")
	    			.setIndicator("Elementen", res.getDrawable(R.drawable.ic_tab_elements))
	    			.setContent(intent);
	    tabHost.addTab(spec);

	    // Do the same for the other tabs
	    intent = new Intent().setClass(this, ProjectMap.class);
	    intent.putExtra(ProjectDbAdapter.KEY_ROWID, project_id);
	    intent.putExtra(ProjectDbAdapter.KEY_TITLE, strTitle);
	    
	    spec = tabHost.newTabSpec("map")
	    			.setIndicator("Kaart", res.getDrawable(R.drawable.ic_tab_elements))
	    			.setContent(intent);
	    tabHost.addTab(spec);

	    tabHost.setCurrentTab(0);
	}
}
